home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6034 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: hex to dec function?
  5. Date: 21 Feb 1996 13:40:48 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4gg3h0INN59e@keats.ugrad.cs.ubc.ca>
  8. References: <4gdh1b$bg@mailhost.mwmicro.com> <4gdolr$ha9@madeline.INS.CWRU.Edu>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4gdolr$ha9@madeline.INS.CWRU.Edu>,
  12. Michael A. Balfour <mab22@po.CWRU.Edu> wrote:
  13.  >
  14.  >In a previous article, aschlies@citynet.net () says:
  15.  >
  16.  >>Hi There,
  17.  >>
  18.  >>Is there a function that converts HEX to Dec in ANSI C?
  19.  >>
  20.  >You could try sscanf.  For example:
  21.  >
  22.  >main()
  23.  >{
  24.  >  char hex[9];
  25.  >  int dec;
  26.  >
  27.  >  strcpy(hex,"FFFF");
  28.  
  29. Of course, someone will change the above to "         FFFFF", thus clobbering
  30. your activation record, since you comitted the hex array to hold only 9
  31. characters. 
  32.  
  33. There is no reason why you can't use   char *hex = "FFFF";  in such a small
  34. example.
  35. -- 
  36.  
  37.